//
//  BaseTableViewController.swift
//  sinaWeibo
//
//  Created by 张国梁 on 16/3/28.
//  Copyright © 2016年 CoderGL. All rights reserved.
//

import UIKit

class BaseTableViewController: UITableViewController, VisitorViewDelegate {

    var isLogin = UserAccount.isOAuth()
    var visitorView: VisitorView?
    
    override func loadView() {
        isLogin ? super.loadView() : setupVisitor()
    }
    
    private func setupVisitor() {
        visitorView = VisitorView()
        visitorView?.delegate = self
        view = visitorView
        
        navigationItem.leftBarButtonItem = UIBarButtonItem(title: "注册", style: UIBarButtonItemStyle.Plain, target: self, action: #selector(BaseTableViewController.registerBtnDidClick))
        navigationItem.rightBarButtonItem = UIBarButtonItem(title: "登录", style: UIBarButtonItemStyle.Plain, target: self, action: #selector(BaseTableViewController.loginBtnDidClick))
    }
    
    func registerBtnDidClick() {
        print(#function)
    }
    
    func loginBtnDidClick() {
        
        let nav = MainNavgationController(rootViewController: OAuthViewController())
        presentViewController(nav, animated: true, completion: nil)
        
    }
    
 

}
